import { VC, Component } from '@/VC-vue'
interface LoadingProps {
    loadingText?: string
}

export type loadType = LoadingProps

export const Loading = ({ data, props = {} }: FC<loadType>) => {
    @Component({})
    class Loading extends VC {
        visible: boolean = false

        render() {
            const { loadingText } = props
            return (
                <a-modal
                    visible={this.visible}
                    width={200}
                    footer={null}
                    closable={false}
                    maskClosable={false}
                >
                    <div class="is-flex">
                        <a-spin>
                            <a-icon
                                slot="indicator"
                                type="loading"
                                style="font-size: 24px"
                                spin
                            />
                        </a-spin>
                        <a style="margin-left:20px">
                            {loadingText || 'loading...'}
                        </a>
                    </div>
                </a-modal>
            )
        }
        /** 打开弹窗 */
        open() {
            this.visible = true
        }

        /**  关闭 弹窗model  */
        cancel() {
            this.visible = false
        }
    }

    return <Loading {...data} />
}
